import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout/index.vue'
// import {
//   getToken,
//   setToken,
//   removeToken,
//   getStoreId,
//   setStoreId,
//   removeStoreId,
//   setUserInfo,
//   getUserInfo,
//   removeUserInfo
// } from "@/utils/cookies";
// import store from "@/store";

Vue.use(Router)

const router = new Router({
  scrollBehavior: (to, from, savedPosition) => {
    if (savedPosition) {
      return savedPosition
    }
    return { x: 0, y: 0 }
  },
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/login',
      component: () => import('@/views/login/index.vue'),
      meta: { title: '苍穹外卖', hidden: true, notNeedAuth: true }
    },
    {
      path: '/404',
      component: () => import('@/views/404.vue'),
      meta: { title: '苍穹外卖', hidden: true, notNeedAuth: true }
    },
    {
      path: '/',
      component: Layout,
      /* 
      侧边栏（Sidebar）中的 router-link 组件设置了 to 属性，这个属性指定了当用户点击这个链接时应该导航到的路由路径。当用户点击这个 router-link 时，Vue Router 会更新当前的路由，并准备渲染与这个新路由匹配的组件。由于 <router-view /> 组件被放置在 AppMain 组件的模板内，Vue Router 会把与新路由匹配的组件渲染到 AppMain 组件内部的 <router-view /> 位置。这是因为 <router-view /> 是 Vue Router 用来渲染当前路由对应组件的出口。在你的应用中，Layout 组件作为一个容器，包含了侧边栏（Sidebar）、导航栏（Navbar）以及 AppMain 组件。AppMain 组件中的 <router-view /> 则负责渲染具体的页面内容（即子路由组件）。当用户点击侧边栏中的 router-link 时，Vue Router 会根据 to 属性指定的路由路径找到匹配的子路由组件，并将其渲染到 AppMain 组件中的 <router-view /> 位置。 
      */
      redirect: '/dashboard',
      children: [
        {
          path: 'dashboard',
          component: () => import('@/views/dashboard/index.vue'),
          name: 'Dashboard',
          meta: {
            title: '工作台',
            icon: 'dashboard',
            affix: true
          }
        },
        {
          path: '/statistics',
          component: () => import('@/views/statistics/index.vue'),
          meta: {
            title: '数据统计',
            icon: 'icon-statistics'
          }
        },
        {
          path: 'order',
          component: () => import('@/views/orderDetails/index.vue'),
          meta: {
            title: '订单管理',
            icon: 'icon-order'
          }
        },
        {
          path: 'setmeal',
          component: () => import('@/views/setmeal/index.vue'),
          meta: {
            title: '套餐管理',
            icon: 'icon-combo'
          }
        },
        {
          path: 'dish',
          component: () => import('@/views/dish/index.vue'),
          meta: {
            title: '菜品管理',
            icon: 'icon-dish'
          }
        },
        {
          path: '/dish/add',
          component: () => import('@/views/dish/addDishtype.vue'),
          meta: {
            title: '添加菜品',
            hidden: true
          }
        },

        {
          path: 'category',
          component: () => import('@/views/category/index.vue'),
          meta: {
            title: '分类管理',
            icon: 'icon-category'
          }
        },
        {
          path: 'employee',
          component: () => import('@/views/employee/index.vue'),
          meta: {
            title: '员工管理',
            icon: 'icon-employee'
          }
        },

        {
          path: '/employee/add',
          component: () => import('@/views/employee/addEmployee.vue'),
          meta: {
            title: '添加/修改员工',
            hidden: true
          }
        },

        {
          path: '/setmeal/add',
          component: () => import('@/views/setmeal/addSetmeal.vue'),
          meta: {
            title: '添加套餐',
            hidden: true
          }
        },
        {
          path: '/employee/add',
          component: () => import('@/views/employee/addEmployee.vue'),
          meta: {
            title: '添加/修改员工',
            hidden: true
          }
        }
      ]
    },
    {
      path: '*',
      redirect: '/404',
      meta: { hidden: true }
    }
  ]
})

export default router
